#!/usr/bin/env python
# -*- coding: utf-8 -*-


import sys
import urllib
from os import path


def main():
    if len(sys.argv) == 2:
        base_path = sys.argv[1]
    else:
        base_path = 'runtime/mafengwo'
    for i in range(1, 47):
        url = 'https://images.mafengwo.net/images/signup/wallpaper/{:d}.jpg'.format(i)

        filename = path.join(base_path, path.basename(url))

        print('Getting image from {:s}]'.format(url))
        urllib.urlretrieve(url, filename)
        print('Save image to {:s}'.format(filename))


if __name__ == '__main__':
    main()